package com.zjw.yyyy2021.mmdd0925;

/**
 * <p></p>
 *
 * @author 郑大仙丶
 * @version V1.0.0
 * @date 2021/9/25 22:55
 */
public class MMdd0925 {

    public static ListNode reverseList(ListNode head) {
        if (head == null) return null;
        ListNode pre = null;
        ListNode next = null;
        while (head.next != null) {
            next = head.next;
            head.next = pre;
            pre = head;
            head = next;
        }
        head.next = pre;
        return head;
    }


}

class ListNode {
    int val;
    ListNode next = null;

    ListNode(int val) {
        this.val = val;
    }
}
